

package trabajospracticosavanzadaii;


public class Pila{
    private String[] pila;
    private int tope;
    
   public Pila(int n){      //constructor
       pila = new String [n];
       tope= -1;     
    } 
   
    public void apilar(String dato){
        tope++;
        pila[tope]= dato;
    }
    
    public String desapilar(){
        String aux = pila[tope];
        tope--;
        return aux;
    }
    
    public boolean llena(){
        if(pila.length-1==tope)
            return true;
        else
            return false;
    }
    public boolean vacia(){
        if(tope==-1)
            return true;
        else
            return false;
    }    
    public String topePila(){
        return pila[tope];
    }
            
        }
        
    

